queue *elem, *tmp;
field_map_t *fmp;
ogue_t *ogp;
+ route_head *rte = NULL;
+ route_head *trk = NULL;
+ if (xcsv_file.datatype == trkdata) {
+ trk = route_head_alloc();
+ track_add_head(trk);
+ } else
+ if (xcsv_file.datatype == rtedata) {
+ rte = route_head_alloc();
+ route_add_head(rte);
+ }
+
while ((buff = gbfgetstr(xcsv_file.xcsvfp))) {
linecount++;
/* Whack trailing space; leading space may matter if our field sep
GPS_Math_Known_Datum_To_WGS84_M(wpt_tmp->latitude, wpt_tmp->longitude, 0.0,
&wpt_tmp->latitude, &wpt_tmp->longitude, &alt, xcsv_file.gps_datum);
}
- waypt_add(wpt_tmp);
+ switch(xcsv_file.datatype) {
+ case 0:
+ case wptdata:
+ waypt_add(wpt_tmp); break;
+ case trkdata:
+ track_add_wpt(trk, wpt_tmp); break;
+ case rtedata:
+ route_add_wpt(rte, wpt_tmp); break;
+ default: ;
+ }
}
}
gbfprintf(xcsv_file.xcsvfp, "%s", xcsv_file.record_delimiter);
}
- waypt_disp_all(xcsv_waypt_pr);
- route_disp_all(xcsv_resetpathlen,xcsv_noop,xcsv_waypt_pr);
- track_disp_all(xcsv_resetpathlen,xcsv_noop,xcsv_waypt_pr);
+ if ((xcsv_file.datatype == 0) || (xcsv_file.datatype == wptdata))
+ waypt_disp_all(xcsv_waypt_pr);
+ if ((xcsv_file.datatype == 0) || (xcsv_file.datatype == rtedata))
+ route_disp_all(xcsv_resetpathlen,xcsv_noop,xcsv_waypt_pr);
+ if ((xcsv_file.datatype == 0) || (xcsv_file.datatype == trkdata))
+ track_disp_all(xcsv_resetpathlen,xcsv_noop,xcsv_waypt_pr);
/* output epilogue lines, if any. */
QUEUE_FOR_EACH(&xcsv_file.epilogue, elem, tmp) {
ff_type type; /* format type for GUI wrappers. */
int gps_datum; /* result of GPS_Lookup_Datum_Index */
+ gpsdata_type datatype; /* can be wptdata, rtedata or trkdata */
+ /* ... or ZERO to keep the old behaviour */
} xcsv_file_t;
*/
svp[i]->vec->args++;
}
-
+ memset(&svp[i]->vec->cap, 0, sizeof(svp[i]->vec->cap));
+ switch(xcsv_file.datatype) {
+ case 0:
+ case wptdata:
+ svp[i]->vec->cap[ff_cap_rw_wpt] = ff_cap_read | ff_cap_write; break;
+ case trkdata:
+ svp[i]->vec->cap[ff_cap_rw_trk] = ff_cap_read | ff_cap_write; break;
+ case rtedata:
+ svp[i]->vec->cap[ff_cap_rw_rte] = ff_cap_read | ff_cap_write; break;
+ default: ;
+ }
svp[i]->desc = xcsv_file.description;
svp[i]->parent = "xcsv";
}
is_fatal(xcsv_file.gps_datum < 0, MYNAME ": datum \"%s\" is not supported.", p);
xfree(p);
} else
+
+ if (ISSTOKEN(sbuff, "DATATYPE")) {
+ p = csv_stringtrim(&sbuff[8], "\"", 1);
+ if (case_ignore_strcmp(p, "TRACK") == 0) {
+ xcsv_file.datatype = trkdata;
+ }
+ else if (case_ignore_strcmp(p, "ROUTE") == 0) {
+ xcsv_file.datatype = rtedata;
+ }
+ else if (case_ignore_strcmp(p, "WAYPOINT") == 0) {
+ xcsv_file.datatype = wptdata;
+ }
+ else {
+ fatal(MYNAME ": Unknown data type \"%s\"!\n", p);
+ }
+ xfree(p);
+
+ } else
if (ISSTOKEN(sbuff, "IFIELD")) {
key = val = pfc = NULL;
xcsv_read_style(styleopt);
}
- if (global_opts.masked_objective & (TRKDATAMASK|RTEDATAMASK)) {
- warning(MYNAME " attempt to read %s as a track or route, but this module only supports waypoints on read. Reading as waypoints instead.\n", fname);
+ if ((xcsv_file.datatype == 0) || (xcsv_file.datatype == wptdata)) {
+ if (global_opts.masked_objective & (TRKDATAMASK|RTEDATAMASK)) {
+ warning(MYNAME " attempt to read %s as a track or route, but this format only supports waypoints on read. Reading as waypoints instead.\n", fname);
+ }
}
xcsv_file.xcsvfp = gbfopen(fname, "r", MYNAME);